package com.example.mybatisannotation.mapper;

import com.example.mybatisannotation.entity.Student;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface StuMapper {

    @Insert("insert into tb_student(id,no,name,sex,phone,qq) values (#{id},#{no},#{name},#{sex},#{phone},#{qq})")
    int create(Student student);

    @Select("select * from tb_student where name like concat('%',#{name},'%')")
    List<Student> getByName(String hname);

    @Select("select * from tb_student where id=#{id}")
    Student getByID(Integer id);

    @Delete("delete from tb_student where id=#{id}")
    int deleteById(Integer id);

    @Select("select * from tb_student")
    List<Student> getAllStudents();

    @Update("update tb_student set no=#{no},name=#{name},sex=#{sex},phone=#{phone},qq=#{qq} where id=#{id}")
    int updateStu(Student stu);
}
